﻿@using Model;
@{

    Layout = "~/Admin/_AdminSiteLayout.cshtml";
    Page.Title = "Delete Question Type";

    var statusMessage = "";
    bool isValid = false;

    int requestId = UrlData[0].AsInt();// Request.Form["Id"].AsInt();

    QuestionType aQuestionType = null;

    if (!IsPost)
    {
        aQuestionType = SiteHelper.GetQuestionTypeById(requestId);
    }

    if (IsPost)
    {
        bool isDeleted = SiteHelper.DeleteQuestionTypeById(requestId);

        if (isDeleted)
        {
            statusMessage = " Type Deleted Successfully!";

            isValid = true;
        }
        else
        {
            isValid = false;

            statusMessage = "Error!";
        }
    }
}
@if (!statusMessage.IsEmpty())
{
    if (isValid)
    {
    <p class="message success">
        @statusMessage
    </p>
    }
    else
    {
    <p class="message error">
        @statusMessage
    </p>
    }
}
<form method="post" action="">
<fieldset>
    <legend>Question Type Delete</legend>
    @if (!IsPost)
    {  <label>
        Question Type :
    </label>
        @aQuestionType.QType
        <br />
        <br />
        <br />
        <label>
            Are You sure?</label>
        <p class="form-actions">
            <input class="button thin red" type="submit" value="Yes" title="Delete" />
            <a class="button medium gray"  href="@Href("~/Admin/ViewQuestionType")">No</a>
        </p>
    }
    @if (IsPost)
    {
        <p class="form-actions">
            <a class="button medium green"  href="@Href("~/Admin/ViewQuestionType")">Back to Question
                Type</a>
        </p>
    }
</fieldset>
</form>